use "C:\Users\Jesse\Box Sync\2018 State Elections Paper\CCESFirstRelease2018.dta" 

generate CC18_413d_REP = 1 if CC18_413d ==2
replace CC18_413d_REP = 0 if CC18_413d ==1
generate Trumpdisapproval = CC18_308a if CC18_308a <5
generate Legdisapproval = CC18_308e if CC18_308e <5
generate RepPartyLowChamBelief = 0
replace RepPartyLowChamBelief = 1 if CC18_309d == 1
generate DemPartyLowChamBelief = 0
replace DemPartyLowChamBelief = 1 if CC18_309d == 2



// trump disapproval alone
logit CC18_413d_REP i.Trumpdisapproval 

tabulate CC18_413d_REP Trumpdisapproval, column 

generate TrumpApproval = 1 if Trumpdisapproval <3
replace TrumpApproval = 0 if Trumpdisapproval >2
generate TrumpApproval4 = .
replace TrumpApproval4 = 1 if Trumpdisapproval == 4
replace TrumpApproval4 = 2 if Trumpdisapproval == 3
replace TrumpApproval4 = 3 if Trumpdisapproval == 2
replace TrumpApproval4 = 4 if Trumpdisapproval == 1

tabulate TrumpApproval Trumpdisapproval

tabulate CC18_413d_REP TrumpApproval [aweight = commonweight], column


// state legislative approval alone

logit CC18_413d_REP i.Legdisapproval##i.RepPartyLowChamBelief 


//With trump approval
logit CC18_413d_REP i.gender i.educ i.race i.region i.Trumpdisapproval i.Legdisapproval##i.RepPartyLowChamBelief i.urbancity i.child18 i.unionhh i.CC18_334A i.CC18_335 i.CC18_302 i.CC18_301 i.pid7

//Without Trump approval
logit CC18_413d_REP i.gender i.educ i.race i.region i.Legdisapproval##i.RepPartyLowChamBelief i.urbancity i.child18 i.unionhh i.CC18_334A i.CC18_335 i.CC18_302 i.CC18_301 i.pid7


//race and vote crosstab
tabulate CC18_413d_REP race [aweight = commonweight], column 

tabulate CC18_413d_REP race [aweight = commonweight], row


//race and vote crosstab cuban origin only
tabulate CC18_413d_REP race [aweight = commonweight] if CC18_354a_5 ==1, column

tabulate CC18_413d_REP race [aweight = commonweight] if CC18_354a_3 == 1, column

// vote and Latino national origin
tabulate CC18_413d_REP CC18_354a_1 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_2 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_3 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_4 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_5 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_6 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_7 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_8 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_9 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_10 [aweight = commonweight], column
tabulate CC18_413d_REP CC18_354a_11 [aweight = commonweight], column


// turnout analyses

if tookpost ==2

// 2016 self reported vote.  Note that the missing value is >6
tabulate CC18_317, missing
tabulate CC18_317 if CC18_317 >6, missing

ideo5 newsint faminc_new inputstate birthyr_post

tabulate votereg votereg_post, missing

// problems at polling booth

generate IDorRegProblem = 1 if CC18_406a ==2
replace IDorRegProblem = 0 if CC18_406a ==1

tabulate inputstate CC18_406a [aweight = commonweight], row
logistic IDorRegProblem i.inputstate [pweight = commonweight]

generate Georgia = 1 if inputstate == 13
replace Georgia = 0 if inputstate !=13

//trump vote and turnout
generate Voted = 0 if tookpost ==2 
replace Voted = 1 if CC18_401 == 5
tabulate Voted

logit Voted i.gender i.educ i.race i.region i.Trumpdisapproval i.Legdisapproval##i.RepPartyLowChamBelief i.urbancity i.child18 i.unionhh i.CC18_334A i.CC18_335 i.CC18_302 i.CC18_301 i.pid7 newsint faminc_new i.inputstate birthyr_post

eststo: logit Voted i.TrumpApproval4
eststo: logit Voted i.TrumpApproval4 i.gender i.educ i.race i.region   i.urbancity i.child18 i.unionhh faminc_new i.inputstate birthyr_post [pweight = commonweight]



esttab using tableA2.rtf, star(+ 0.10 * 0.05) se ar2 onecell


eststo clear
eststo: logit Voted i.gender i.educ i.race i.region i.Trumpdisapproval  i.urbancity i.child18 i.unionhh faminc_new i.inputstate birthyr_post if Trumpdisapproval !=1 & Trumpdisapproval !=4 [pweight = commonweight]



logit Voted i.Trumpdisapproval [pweight = commonweight]

tabulate Voted Trumpdisapproval [aweight = commonweight], column
tabulate  CC18_308a  Voted [aweight = commonweight], row

tabulate Voted Trumpdisapproval [aweight = commonweight], column

